package com.example.controller;

import com.example.entity.ResponseEntity;
import com.example.service.impl.VoteServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
public class StudentVoteController {


    @Autowired
    VoteServiceImpl service;


    @GetMapping
    @ResponseBody
    @RequestMapping("/student/vote")
    public ResponseEntity queryAllVote(){
        return ResponseEntity.ok(service.queryAllVote());
    }


    @GetMapping
    @ResponseBody
    @RequestMapping("/student/voting")
    public ResponseEntity Vote(@RequestParam(name = "studentId")String studentId,@RequestParam(name = "count")String count){
        boolean a = service.addVote(studentId,count);
        if (a == true){
            return ResponseEntity.ok("投票成功");
        }else {
            return ResponseEntity.err("投票失败");
        }
    }
}
